<?php

require_once 'Zend/Translate.php';

class Demo_FlashMessengerTranslateDecorator 
{
	const SESSION_KEY = 'messages';
	
	private static $instance = null;
	/**
	 * @var Zend_Translate
	 */
	private $_translator;
	/**
	 * @var Zend_Controller_Action_Helper_FlashMessenger
	 */
	private $_messenger;
	
	public function __construct(Zend_Controller_Action_Helper_FlashMessenger $messenger) {
		$this->_messenger = $messenger;
	}

	public function setTranslator(Zend_Translate $translator) {
		$this->_translator = $translator;
	}
	
	public function addMessage($message) {
		if (isset($this->_translator)) {
			$message = $this->_translator->translate($message);
		}
		
		$this->_messenger->addMessage($message);
	}
}